package com.dfec.water.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dfec.common.exception.ServiceException;
import com.dfec.component.uid.core.service.UidService;
import com.dfec.framework.mybatis.core.page.PageParam;
import com.dfec.framework.mybatis.core.page.PageUtils;
import com.dfec.water.dao.YdbAreaDeviceDao;
import com.dfec.water.dao.YdbDeviceTypeDao;
import com.dfec.water.dao.YdbDeviceZsyDao;
import com.dfec.water.entity.YdbAreaDeviceEntity;
import com.dfec.water.entity.YdbDeviceZsyEntity;
import com.dfec.water.service.YdbDeviceTypeService;
import com.dfec.water.service.YdbDeviceZsyService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.List;

/**
 * @author df
 * @title: YdbDeviceTypeServiceImpl
 * @description: 设备类别Service业务层处理
 * @date Fri Jan 10 15:02:12 CST 2025
 */
@Service
@RequiredArgsConstructor
public class YdbDeviceZsyServiceImpl extends ServiceImpl<YdbDeviceZsyDao, YdbDeviceZsyEntity> implements YdbDeviceZsyService {

    private final YdbDeviceZsyDao ydbDeviceTypeDao;

    private final UidService uidService;


    /**
     * 分页查询
     *
     * @param pageParam 入参
     * @return PageUtils
     * @author df
     * @date Fri Jan 10 15:02:12 CST 2025
     */
    @Override
    public PageUtils queryPage(PageParam<YdbDeviceZsyEntity> pageParam) {
        return ydbDeviceTypeDao.selectPage(pageParam);
    }

    /**
     * 不带分页查询
     *
     * @param ydbDeviceTypeEntity 入参
     * @return List<YdbDeviceZsyEntity>
     * @author df
     * @date Fri Jan 10 15:02:12 CST 2025
     */
    @Override
    public List<YdbDeviceZsyEntity> listAll(YdbDeviceZsyEntity ydbDeviceTypeEntity) {
        return ydbDeviceTypeDao.selectAll(ydbDeviceTypeEntity);
    }


    @Override
    public boolean save(YdbDeviceZsyEntity entity) {
        entity.setId(uidService.next());
        return super.save(entity);
    }

    @Override
    public boolean removeByIds(Collection<?> list) {
        //校验当前设备是否已经绑定
        return super.removeByIds(list);
    }

    @Override
    public boolean saveBatch(Collection<YdbDeviceZsyEntity> entityList) {
        entityList.forEach(entity -> entity.setId(uidService.next()));
        return super.saveBatch(entityList);
    }
}